#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<unistd.h>

int main(int argc, char *argv[])
{
  static char cwd[256];
  static size_t cwdlen;
  if(cwdlen){
    printf("Error!!!\n");
    return 1;
  }

  if(!getcwd(cwd,sizeof(cwd))){
    const char *pwd = getenv("PWD");
    if(pwd && strlen(pwd) < sizeof(cwd))
      strcpy(cwd,pwd);
  }

  if(*cwd != '/'){
    fprintf(stderr,"Can't get current working directory\n");
    exit(-1);
  }

  cwdlen = strlen(cwd);

  if(cwd[cwdlen - 1] != '/'){
    cwd[cwdlen++] = '/';
    cwd[cwdlen] = 0;
  }

  printf("%s\n",cwd);
  return 0;
}
